package com.erpanderp.wam.usm.view.user;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.erpanderp.wam.tm.model.entity.Technology;
import com.erpanderp.wam.usm.model.entity.user.NewJoinee;
import com.erpanderp.wam.usm.model.entity.user.PassportAndPANDetails;
import com.erpanderp.wam.usm.model.entity.user.WAMUser;
import com.erpanderp.wam.usm.model.service.user.NewJoineeDAO;
import com.erpanderp.wam.usm.model.service.user.PassportAndPANDAO;
import com.erpanderp.wam.usm.model.service.user.WAMUserDAO;
import com.erpanderp.wam.util.CommonLookup;
import com.erpanderp.wam.util.ValidationUtil;


@ViewScoped
@ManagedBean
public class EformListBean {
	
	HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
			.getExternalContext().getSession(true);
	HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
	private WAMUser wamUser = (WAMUser) session.getAttribute(CommonLookup.SESSION_ATTRIBUTE_WAMUSER);
	PassportAndPANDAO passportAndPANDAO =new PassportAndPANDAO();
    NewJoineeDAO newJoineeDAO = new NewJoineeDAO();
    List<NewJoinee> newJoineesList = new ArrayList<NewJoinee>();
    private NewJoinee newJoinee= new NewJoinee();
    private PassportAndPANDetails passportandPANdetails = new PassportAndPANDetails();
    
    
    public EformListBean(){
    	if(wamUser == null)	ValidationUtil.gotoLoginPage();
		newJoineesList = newJoineeDAO.getAllNewJoinees();		
	}
    
    public String vieweform(){
    	
    	     session.setAttribute("newJoinee", newJoinee);
    	
    	
    		 System.out.println("=====INSIDE VIEW EFORM METHOD=======");
    		 try{
    		  Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    		  
    		  //String newJoineeId = params.get("newJoineeId");
    		  
    		  newJoinee = (NewJoinee) session.getAttribute("newJoinee");

    		  	  
    		 
    		  
    		 
    		  
    		  
    		 
    		  }catch (Exception e) {
    			  System.out.println("INSIDE CATCH EXCPTION:::::::::"+e);
    			  e.printStackTrace();
    		 }
    		 return "eformview";
    	 
    }
    
    
	public List<NewJoinee> getNewJoineesList() {
		return newJoineesList;
	}
	public void setNewJoineesList(List<NewJoinee> newJoineesList) {
		this.newJoineesList = newJoineesList;
	}

	public NewJoinee getNewJoinee() {
		return newJoinee;
	}

	public void setNewJoinee(NewJoinee newJoinee) {
		this.newJoinee = newJoinee;
	}

	public PassportAndPANDetails getPassportandPANdetails() {
		return passportandPANdetails;
	}

	public void setPassportandPANdetails(PassportAndPANDetails passportandPANdetails) {
		this.passportandPANdetails = passportandPANdetails;
	}


	  




}


    
    
    

	
	
	
	
	
	
	
	

